package com.shujia.mr.tuijian;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class PersonReducer extends Reducer<Text, LongWritable, Text, Text> {
    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Reducer<Text, LongWritable, Text, Text>.Context context) throws IOException, InterruptedException {
        //<tom-hello,[1,-1,-1,1]>
        boolean flag = true;
        for (LongWritable value : values) {
            long l = value.get();
            if(l==1){
                flag=false;
                context.write(key,new Text("--直接好友--"));
                break;
            }
        }

        if(flag){
            context.write(key,new Text("--间接好友--"));
        }
    }
}
